package com.itheima.project.web;

import com.itheima.project.basic.ResponseWrap;
import com.itheima.project.core.enums.trade.TradingEnum;
import com.itheima.project.face.CashPayFace;
import com.itheima.project.utils.ResponseWrapBuild;
import com.itheima.project.vo.trade.TradingVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName CashPayFace.java
 * @Description 现金支付方式：商户收钱直接操作
 */
@RestController
@RequestMapping("trade-cash")
@Api(tags = "现金支付controller")
public class CashPayController {

    @Autowired
    CashPayFace cashPayFace;

    /***
     * @description 现金支付方式：商户收钱直接操作接口
     * @param tradingVo 交易单
     * @return  交易单
     */
    @PostMapping("create-cash-trading")
    @ApiOperation(value = "现金支付",notes = "现金支付")
    @ApiImplicitParam(name = "tradingVo",value = "交易单",required = true,dataType = "TradingVo")
    ResponseWrap<TradingVo> createCashTrading(@RequestBody TradingVo tradingVo){
        TradingVo tradingVoResult = cashPayFace.createCashTrading(tradingVo);
        return ResponseWrapBuild.build(TradingEnum.SUCCEED,tradingVoResult);
    }

    /***
     * @description 现金退款
     * @param tradingVo 交易单
     * @return  交易单
     */
    @PostMapping("refund-cash-trading")
    @ApiOperation(value = "现金退款",notes = "现金退款")
    @ApiImplicitParam(name = "tradingVo",value = "交易单",required = true,dataType = "TradingVo")
    ResponseWrap<TradingVo> refundCashTrading(@RequestBody TradingVo tradingVo){
        TradingVo tradingVoResult = cashPayFace.refundCashTrading(tradingVo);
        return ResponseWrapBuild.build(TradingEnum.SUCCEED,tradingVoResult);
    }
}
